import { Provide } from '@midwayjs/decorator';
import { BaseService } from '@cool-midway/core';
import { InjectEntityModel } from '@midwayjs/typeorm';
import { Repository } from 'typeorm';
import { BannerEntity } from '../entity/banner';

/**
 * 轮播图
 */
@Provide()
export class BannerService extends BaseService {
    @InjectEntityModel(BannerEntity)
    bannerEntity: Repository<BannerEntity>;

    /**
     * 轮播图列表
     */
    async getBanner() {
        try {
            const list = await this.bannerEntity.find({ where: { status: 1 } });
            return {
                success: true,
                message: '查询成功',
                data: list,
            }
        } catch (error) {
            throw new Error(error);
        }
    }
}
